package com.xzcedu.writer_;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

/**
 * @author 徐州城
 * @version 1.0
 * 演示BufferedWriter 使用
 * 使用BufferedWriter 将 "hello,韩顺平教育"，写如文件中
 */
public class BufferedWriter_ {
    public static void main(String[] args) throws Exception {

        String filePath = "e:\\ok.txt";
        //创建BufferedWriter
        BufferedWriter bufferedReader = new BufferedWriter(new FileWriter(filePath, true));
        bufferedReader.write("hell,韩顺平教育!");
        bufferedReader.newLine();//插入一个和系统相关的换行符
        bufferedReader.write("hell,韩顺平教育!");
        bufferedReader.newLine();
        bufferedReader.write("hell,韩顺平教育!");
        bufferedReader.newLine();
        //插入一个换行

        //说明：关闭外层流即可，传入的 New FileWriter(filePath) 会再底层关闭
        bufferedReader.close();
    }
}
